package com.gobo.eduoss.controller;

import com.gobo.commonutils.R;
import com.gobo.eduoss.service.OssFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/eduoss/fileoss")
public class OssFileController {

    @Autowired
    private OssFileService fileService;

    @PostMapping("/upload/{typeName}")
    public R uploadOssFile(MultipartFile file, @PathVariable String typeName){
        String s = fileService.uploadFile(file,typeName);
        return R.ok().data("url",s);
    }
    @PostMapping("/deleteFiles")
    public R removeFiles(@RequestParam List<String> fileNames){
        fileService.removeFiles(fileNames);
        return R.ok();
    }
    @PostMapping("/deleteFile")
    public R removeFile(@RequestParam String fileId){
        fileService.removeFile(fileId);
        return R.ok();
    }
}
